package com.zhai.test.domain.credit;

import com.zhai.domain.credit.model.entity.TradeEntity;
import com.zhai.domain.credit.model.valobj.TradeNameVO;
import com.zhai.domain.credit.model.valobj.TradeTypeVO;
import com.zhai.domain.credit.service.CreditAdjustService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @Description: 积分调额测试类
 * @ClassName: CreditAdjustTest
 * @Author: zhaiyongxin
 * @Date: 2025/6/24 13:29
 * @Version: 1.0
 */
@SpringBootTest
@RunWith(SpringRunner.class)
@Slf4j
public class CreditAdjustTest {
    @Resource
    private CreditAdjustService creditAdjustService;

    /**
     * 积分调增
     */
    @Test
    public void  test_createOrder_up(){
        TradeEntity tradeEntity = new TradeEntity();
        tradeEntity.setTradeType(TradeTypeVO.FORWARD);
        tradeEntity.setTradeName(TradeNameVO.REBATE);
        tradeEntity.setUserId("zhaiyongxin");
        tradeEntity.setOutBusinessNo("20250624");
        tradeEntity.setAmount(new BigDecimal("10"));
        String order = creditAdjustService.createOrder(tradeEntity);
        log.info("积分调增 request:{}",tradeEntity);
        log.info("积分调增 response:{}",order);
    }

    /**
     * 积分调减
     */
    @Test
    public void  test_createOrder_down(){
        TradeEntity tradeEntity = new TradeEntity();
        tradeEntity.setTradeType(TradeTypeVO.REVERSE);
        tradeEntity.setTradeName(TradeNameVO.REBATE);
        tradeEntity.setUserId("zhaiyongxin");
        tradeEntity.setOutBusinessNo("20250624-down");
        tradeEntity.setAmount(new BigDecimal("-10"));
        String order = creditAdjustService.createOrder(tradeEntity);
        log.info("积分调减 request:{}",tradeEntity);
        log.info("积分调减 response:{}",order);
    }
}
